Microsoft DirectX 8.1 (C++)

Media Samples and Media Types

When two filters connect, they must agree on the kind of data that the upstream filter will deliver to the downstream filter. This ensures that the downstream filter can process the data it receives. In DirectShow, data formats are described using the AM_MEDIA_TYPE structure, which is also called the media type. Every pin connection has an established media type. Some pins can accept a wide range of media types, while others are limited one or two types. For details about the connection process, see How Filters Connect.

Once the filters have connected, the upstream filter can send media data to the downstream filter, via the pin connection. The upstream filter packages the data inside a COM object, called a media sample. Media samples implement the IMediaSample or IMediaSample2 interface. In addition to the actual data, the media sample contains a time stamp, which specifies the sample's presentation time.

Typically, a video media sample contains a single frame, and an audio media sample contains several audio samples.

Filters automatically allocate the memory buffers needed to hold the data in a media sample. For this purpose, filters use helper objects called allocators. For more information, see Data Flow in the Filter Graph.